import { API } from '@/services/model/baseModel';
import { FileModel } from '@/services/model/fileModel';
import { SensitiveDataModel, UserInfoModel } from '@/services/model/userModel';
import config from '@/utils/config';
import { request } from '@/utils/http';

/**
 * 获取登录人信息
 * @returns res
 */
const getUserInfo = () => {
  // 实际地址http://localhost:9197/caac-admin/api/button/jldMs?systemKey=xintianhe_hb&systemFlag=yidong
  return request.get<API<UserInfoModel>>(config.url.user);
};

/**
 * 获取敏感数据
 * @returns res
 */
const getSensitiveData = () => {
  // 实际地址http://localhost:9197/caac-admin/api/button/jldMs?systemKey=xintianhe_hb&systemFlag=yidong
  return request.get<API<SensitiveDataModel>>(config.url.sensitive);
};

/**
 * 修改昵称
 * @param nickname 昵称
 * @returns res
 */
const editNickname = (nickname: string) => {
  return request.post<API<String>>(config.url.nickname, { nickname: nickname });
};

/**
 * 修改签名
 * @param signatur 签名
 * @returns res
 */
const editSignature = (signatur: string) => {
  return request.post<API<String>>(config.url.signatur, { signatur: signatur });
};

/**
 * 修改性别
 * @param gender 性别
 * @returns res
 */
const editGender = (gender: string) => {
  return request.post<API<String>>(config.url.gender, { gender: gender });
};

/**
 * 修改生日
 * @param birthday 生日
 * @returns res
 */
const editBirthday = (birthday: string) => {
  return request.post<API<String>>(config.url.birthday, { birthday: birthday });
};

/**
 * 修改地区
 * @param area 地区
 * @returns res
 */
const editArea = (area: string) => {
  return request.post<API<String>>(config.url.area, { area: area });
};

/**
 * 修改头像
 * @param area 地区
 * @returns res
 */
const editAvatar = (avatar: String) => {
  return request.post<API<String>>(config.url.avatar, { avatar: avatar });
};

/**
 * 实名认证
 * @param area 地区
 * @returns res
 */
const realnameAuthentication = (params: Object) => {
  return request.post<API<String>>(config.url.avatar, params);
};

export {
  getUserInfo,
  getSensitiveData,
  editNickname,
  editSignature,
  editGender,
  editBirthday,
  editArea,
  editAvatar,
  realnameAuthentication,
};
